package practice;

import java.util.*;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName Mian.java
 * @createTime 2022年06月10日 19:02:00
 */
public class Mian {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		int index=0;
		String result="";
		String temp="";
		Stack<Character> stack=new Stack<>();

		while (index<str.length()){
			if (str.charAt(index)==']'){
				String innerTemp="";
				temp="";
				while (stack.size()>0){
					Character pop = stack.pop();
					if (Character.isAlphabetic(pop)){
						innerTemp=pop+innerTemp;
					}else if (Character.isDigit(pop)){
						for (int i1 = 0; i1 < Integer.parseInt(pop.toString()); i1++) {
							temp+=innerTemp;
						}
					}
				}
				result+=temp;
			}
			stack.push(str.charAt(index));
			index+=1;
		}
		System.out.println(result);
	}
}
